Unable to cast object of type 'System.Byte[]' to type 'System.IConvertible'.

Posted by alvn.dsza on Stack Overflow See other posts from Stack Overflow or by alvn.dsza
Published on 2010-06-05T06:28:10Z Indexed on 2010/06/05 6:32 UTC
Read the original article Hit count: 203

Filed under:

i get the error in following code

Function ReadFile(ByVal sPath As String) As Byte

    Dim data As Byte
    data = Nothing

    Dim fInfo As FileInfo
    fInfo = New FileInfo(sPath)

    Dim numBytes As Long
    numBytes = fInfo.Length

    Dim fStream As FileStream
    fStream = New FileStream(sPath, FileMode.Open, FileAccess.Read)

    Dim br As BinaryReader
    br = New BinaryReader(fStream)

    data = Convert.ToByte(br.ReadBytes(numBytes)) `getting error on this line`
    Return data
End Function

© Stack Overflow or respective owner

Related posts about vb.net